using System;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Data;

namespace Converters
{
	public class IsEnableMultiConverter : IMultiValueConverter
	{
		public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
		{
			if (parameter == null)
			{
				return false;
			}
			if (parameter.ToString().Equals("Copy") && value.Count() >= 1 && value[0] != null && value[0] != DependencyProperty.UnsetValue)
			{
				if (!string.IsNullOrEmpty(value[0].ToString()))
				{
					return true;
				}
			}
			else if (parameter.ToString().Equals("Paste") && value.Count() == 2 && value[0] != null && value[1] != null && value[0] != DependencyProperty.UnsetValue && value[1] != DependencyProperty.UnsetValue && !string.IsNullOrEmpty(value[0].ToString()) && !string.IsNullOrEmpty(value[1].ToString()) && value[0].ToString().Equals(value[1].ToString()))
			{
				return true;
			}
			return false;
		}

		public object[] ConvertBack(object value, Type[] targetType, object parameter, CultureInfo culture)
		{
			return null;
		}
	}
}
